package fussbudget.gui;

import java.awt.Component;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import fussbudget.PaymentEntity;

public class PaymentEntityComboBox extends JComboBox {

	public PaymentEntityComboBox(DefaultComboBoxModel model) {
		super(model);
		this.setRenderer(new Renderer());
	}

	public class Renderer implements ListCellRenderer {
		public Renderer() {
		}

		@Override
		public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
			if (value != null) {
				return new JLabel(((PaymentEntity)value).getName());
			} else {
				return new JLabel("");
			}
		}
	}
}
